package com.huangliusong.desigin.pattern.creational.singleton;

/**
 * 静态内部类
 * @author huangliusong
 * @since 2018/10/10
 * {@link }
 */
public class StaticInnerClassSingleton {
    private static class InnerClass{
        private static StaticInnerClassSingleton staticInnerClassSingleton=new StaticInnerClassSingleton();
    }

    public static StaticInnerClassSingleton getInstance(){
        return InnerClass.staticInnerClassSingleton;
    }
    private StaticInnerClassSingleton(){
    //私有
        if (InnerClass.staticInnerClassSingleton!=null){
            throw new RuntimeException("单li构造器禁止进行反射");
        }
    }
}
